<cfif isdefined("url.KeyID")>
<CFQUERY NAME="getprod" DATASOURCE="#dsn#">
select *
from tblproducts
where ProdID = '#ProdID#'
</CFQUERY>
<!---add back to inventory......................................................
--->

<cfset myqty = #getprod.Qty# + 1>



<cfquery datasource="#dsn#">
update tblproducts
set Qty = #myqty#
where ProdID = '#ProdID#'
</cfquery>



<cfquery datasource="#dsn#">
INSERT INTO tblinventory(ReceiptNum, ProdID, Price, DateIn, DODAAC, Username, Terminal, Qty, TransType, Cost)
VALUES(#session.ReceiptNum#, 
'#ProdID#', 
#getprod.Price#, 
<cfqueryparam cfsqltype="cf_sql_timestamp" value="#today#">,
<cfif isdefined("session.DODAAC")>#session.DODAAC#<cfelse>null</cfif>,
'#session.username#',
#session.terminal#,
#getprod.Qty#,
'VOID',
#getprod.Cost#)
</cfquery>






<CFQUERY NAME="getprod" DATASOURCE="#dsn#">
select *
from tbltransactions
where ProdID = '#ProdID#' and ReceiptNum = #session.ReceiptNum#
</CFQUERY>

<cfoutput query="getprod" maxrows="1">
<cfquery datasource="#dsn#">
delete
from tbltransactions
where ProdID = '#ProdID#' and ReceiptNum = #session.ReceiptNum#
</cfquery>

</cfoutput>

<cfoutput>

<CFQUERY NAME="Recordset1" DATASOURCE="#dsn#">
select sum(Price) as total, sum(TaxAmount) as taxtotal
from tbltransactions
where ReceiptNum = #session.ReceiptNum#
</CFQUERY>
<!---update main invoice with total amount-------------------->

<cfset mytaxtotal = #Recordset1.total# + #Recordset1.taxtotal#>

<cfquery datasource="#dsn#">
update tblorders
set Amount = #mytaxtotal#
where ReceiptNum = #session.ReceiptNum# 
</cfquery>





</cfoutput>



<cflocation url="product.cfm">
</cfif>